<extend name="common:base" />
<block name="content">
    <div id="header">
        <div class="header">
            <h1 class="tit">{$site_title}</h1>
            <!--<p class="goback">-->
                <!--<a class="return" href="javascript:history.go(-1);">返回</a>-->
            <!--</p>-->
            <!--<p class="more"><a class="share" href=""></a></p>-->
        </div>
    </div>
    <div class="banx-a">
        <ul class="uls">
            <input type="hidden" value="1" class="status">
            <li><a class="page_active" href="javascript:void(0);" onclick="switchstatus('1',this)">未联系</a></li>
            <li><a  href="javascript:void(0);" onclick="switchstatus('2',this)">已联系</a></li>
            <li><a  href="javascript:void(0);" onclick="switchstatus('3',this)">已转化</a></li>
            <!--<li><a href="{:U('Customers/index')}" <if condition="$by eq ''">class="page_active"</if>>未联系</a></li>-->
            <!--<li><a href="{:U('Customers/index', array('by' =>'contact'))}" <if condition="$by eq 'contact'">class="page_active"</if>>已联系</a></li>-->
            <!--<li><a href="{:U('Customers/index', array('by' =>'conversion'))}" <if condition="$by eq 'conversion'">class="page_active"</if>>已转化</a></li>-->
        </ul>
        <div class="zm notcontact" id="mescroll">
            <ul class="ul_notcontact" id="dataList">
                <foreach name="notcontact" item="notcontact">
                    <a href="{:U('Customers/mem_view' ,array('id'=> $notcontact['member_id']))}">
                        <li>{$notcontact['member_name']}
                            <span class="fright">
                                <if condition="$notcontact['mobile'] neq ''">
                                    手机：{$notcontact['mobile']}
                                    <else/>
                                    微信：{$notcontact['wx']}
                                </if>
                            </span>
                        </li>
                    </a>
                </foreach>
                <empty name="notcontact">
                    <div class="no_data">
                        <img src="{:C('__STATIC__')}{$theme}/Static/img/no_data.png" class="tip_img"/>
                        <p class="tip_txt">暂时没有相关信息</p>
                    </div>
                </empty>
            </ul>
        </div>

    <div class="zm contact" style="display: none">
        <ul class="ul_contact">
            <foreach name="contact" item="contact">
                <a href="{:U('Customers/mem_view' ,array('id'=> $contact['member_id']))}">
                    <li>{$contact['member_name']}
                        <span class="fright">
                                <if condition="$contact['mobile'] neq ''">
                                    手机：{$contact['mobile']}
                                    <else/>
                                    微信：{$contact['wx']}
                                </if>
                            </span>
                    </li>
                </a>
            </foreach>
            <empty name="contact">
                <div class="no_data">
                    <img src="{:C('__STATIC__')}{$theme}/Static/img/no_data.png" class="tip_img"/>
                    <p class="tip_txt">暂时没有相关信息</p>
                </div>
            </empty>
        </ul>
    </div>

    <div class="zm translate" style="display: none">
        <ul class="ul_translate">
            <foreach name="translate" item="translate">
                <a href="{:U('Customers/mem_view' ,array('id'=> $translate['member_id']))}">
                    <li>{$translate['member_name']}
                        <span class="fright">
                                <if condition="$translate['mobile'] neq ''">
                                    手机：{$translate['mobile']}
                                    <else/>
                                    微信：{$translate['wx']}
                                </if>
                            </span>
                    </li>
                </a>
            </foreach>
            <empty name="translate">
                <div class="no_data">
                    <img src="{:C('__STATIC__')}{$theme}/Static/img/no_data.png" class="tip_img"/>
                    <p class="tip_txt">暂时没有相关信息</p>
                </div>
            </empty>
        </ul>
    </div>
</div>
    <div class="dropload-load" id="loading" style="display: none;"><span class="loading"></span>加载中...</div>
</block>
<block name="CSS">
    <link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/khlb-wlx.css" />
</block>

<block name="JS">
    <script type="text/javascript">
            function switchstatus(i, obj) {
                $('#loading').hide();
                if (!($(obj).hasClass("page_active"))) {
                    $(obj).addClass("page_active");
                    $(obj).parent().siblings().find("a").removeClass("page_active");
                }
                if (i == "1") {
                    $('.notcontact').show();
                    $('.contact').hide();
                    $('.translate').hide();
                    $('.status').val('1');
                } else if (i == "2") {
                    $('.notcontact').hide();
                    $('.contact').show();
                    $('.translate').hide();
                    $('.status').val('2');
                } else {
                    $('.notcontact').hide();
                    $('.contact').hide();
                    $('.translate').show();
                    $('.status').val('3');
                }
            }


            /**
             * 继续加载猜您喜欢
             * */
            var before_request = 1; // 上一次请求是否已经有返回来, 有才可以进行下一次请求
            var page = 1;

            function ajax_sourch_submit() {
                if (before_request == 0)// 上一次请求没回来 不进行下一次请求
                    return false;
                before_request = 0;
                page++;
                $.ajax({
                    url:"{:U('Customers/get_more')}",
                    type: "post",
                    data: {
                        status:$(".status").val(),
                        page:page
                    },
                    beforeSend:function() {
                        $('#loading').show();
                    },
                    success: function (msg) {
                        $('#loading').show();
                        if (msg!=1) {
                            if ($(".status").val() == "1") {
                                $('.notcontact').append(msg);
                            } else if ($(".status").val() == "2") {
                                $('.contact').append(msg);
                            }else{
                                $('.translate').append(msg);
                            }
                            before_request = 1;
                        } else{
                            $("#loading").text("亲没有更多的数据了！");
                        }
                    }
                });
            }

//            var pagenum = 1;
//            $(window).scroll(function(){
//
//                var scrollTop = $(this).scrollTop();
//                var scrollHeight = $(document).height();
//                var windowHeight = $(this).height();
//
//                if(scrollTop + windowHeight == scrollHeight){
//                    pagenum += 1;
//                    $.ajax({
//                        url:"{:U('Customers/get_more')}",
//                        type: "post",
//                        data: {
//                            status:$(".status").val(),
//                            page:pagenum
//                        },
//                        success: function (msg) {
//                            $('#loading').show();
//                            if (msg!=1) {
//                                if ($(".status").val() == "1") {
//                                    $('.notcontact').append(msg);
//                                } else if ($(".status").val() == "2") {
//                                    $('.contact').append(msg);
//                                }else{
//                                    $('.translate').append(msg);
//                                }
//                            } else{
//                                    $("#loading").text("亲没有更多的数据了！");
//                            }
//                        }
//                    });
//                }
//        });
    </script>
</block>